package org.link.service;

import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.link.bean.User;
import org.link.dao.UserDao;
import org.springframework.stereotype.Service;

@Service
public class UserService implements IUserService {

	@Resource
	private UserDao userDao;
	@Resource
	private HttpServletRequest request;

	/**
	 * 
	 * description:添加用户
	 * 2015年12月9日 下午2:31:47
	 * @author Link
	 * @param user
	 * @return
	 *
	 */
	public User addUser(User user) {
		
		user.setId(UUID.randomUUID().toString());
		User newUser = userDao.addUsers(user);
		HttpSession session = request.getSession();
		session.setAttribute("name", user.getUsername());
		return newUser;
	}
	
}
